<?php
class SearchController extends Controller
{
	public function actionIndex()
	{
		if(!isset($_GET['type']) || !isset($_GET['key']))
			throw new CHttpException(404,'invalid request');

		if($_GET['type'] == 'group' )
		{
			$data['result']=Group::model()->findAll(array(
				'select'=>'id,name',
				'condition'=>"name LIKE :key",
				'params'=>array(':key'=>'%'.$_GET['key'].'%'),
			));
		}

		$this->render('index',$data);
	}
}
?>
